//
//  HYLSingleton.h
//  单例模式(模式化生成)
//
//  Created by hyl on 16/7/18.
//  Copyright © 2016年 hyl. All rights reserved.
//

#define HYLSingletonH(name) + (instancetype) shared##name;

#define HYLSingletonM(name) \
static id _##instance;\
+(instancetype)allocWithZone:(struct _NSZone *)zone{ \
    static dispatch_once_t onceToken; \
    dispatch_once(&onceToken, ^{ \
        _##instance=[super allocWithZone:zone]; \
    }); \
return _##instance; \
} \
-(id)copyWithZone:(NSZone *)zone{ \
    return _##instance; \
} \
+(instancetype) shared##name{ \
    static dispatch_once_t onceToken; \
    dispatch_once(&onceToken, ^{ \
        _##instance=[[self alloc]init]; \
    }); \
    return _##instance; \
}
